package Servlet;

import DAO.ComplaintDAO;
import DAO.DAOFactory;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.UnsupportedEncodingException;

@WebServlet("/UnassignedComplaint")
public class UnassignedComplaintServlet extends HttpServlet{
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req, resp);
    }

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException, UnsupportedEncodingException {
        req.setCharacterEncoding( "UTF-8" );
        resp.setCharacterEncoding( "UTF-8" );
        ComplaintDAO complaintDAO = (ComplaintDAO) DAOFactory.getComplaintDAOInstance();
        try {
            req.setAttribute("UnassignedComplaintList", complaintDAO.getAllUnassignedComplaint());
            req.getRequestDispatcher("UnassignedComplaint.jsp").forward(req, resp);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
}
